<h1 class="page-title"><?php echo "Dieta"; //@TODO colocar o dia de hoje ?></h1>
<div class="container_12 clearfix leading">
	<input type="hidden" id="id_diet" value="<?php echo $id_diet; ?>"/>
	<input type="hidden" id="id_patient" value="<?php echo $id_patient; ?>"/>
	<? if (isset($dc[1])): ?>
	<section class="portlet grid_12 leading">
		<header>
			<h2>Café da Manhã</h2>
		</header>
		<section>
			<?php
				foreach($dc[1] as $food){
					$checked = '';
					if($food['checked']==1) $checked = 'checked';
					echo'<p>';
					echo'<input name="checkbox'.$food['id'].'" id="checkbox'.$food['id'].'" type="checkbox"'.$checked.'/>';
					echo'		<label for="checkbox'.$food['id'].'">';
					echo'			'.$food['amount_text'].' de '.$food['food_name'];
					echo'		</label>';
					echo'		</p>';
				}
			?>
		</section>
	</section>
	<? endif; ?>
	<? if (isset($dc[2])): ?>
	<section class="portlet grid_12 leading">
		<header>
			<h2>Colação</h2>
		</header>
		<section>
			<?php
				foreach($dc[2] as $food){
					$checked = '';
					if($food['checked']==1) $checked = 'checked';
					echo'<p>';
					echo'<input name="checkbox'.$food['id'].'" id="checkbox'.$food['id'].'" type="checkbox"'.$checked.'/>';
					echo'		<label for="checkbox'.$food['id'].'">';
					echo'			'.$food['amount_text'].' de '.$food['food_name'];
					echo'		</label>';
					echo'		</p>';
				}
			?>
		</section>
	</section>
	<? endif; ?>
	<? if (isset($dc[3])): ?>
	<section class="portlet grid_12 leading">
		<header>
			<h2>Almoço</h2>
		</header>
		<section>
			<?php
				foreach($dc[3] as $food){
					$checked = '';
					if($food['checked']==1) $checked = 'checked';
					echo'<p>';
					echo'<input name="checkbox'.$food['id'].'" id="checkbox'.$food['id'].'" type="checkbox"'.$checked.'/>';
					echo'		<label for="checkbox'.$food['id'].'">';
					echo'			'.$food['amount_text'].' de '.$food['food_name'];
					echo'		</label>';
					echo'		</p>';
				}
			?>
		</section>
	</section>
	<? endif; ?>
	<? if (isset($dc[4])): ?>
	<section class="portlet grid_12 leading">
		<header>
			<h2>Lanche</h2>
		</header>
		<section>
			<?php
				foreach($dc[4] as $food){
					$checked = '';
					if($food['checked']==1) $checked = 'checked';
					echo'<p>';
					echo'<input name="checkbox'.$food['id'].'" id="checkbox'.$food['id'].'" type="checkbox"'.$checked.'/>';
					echo'		<label for="checkbox'.$food['id'].'">';
					echo'			'.$food['amount_text'].' de '.$food['food_name'];
					echo'		</label>';
					echo'		</p>';
				}
			?>
		</section>
	</section>
	<? endif; ?>
	<? if (isset($dc[5])): ?>
	<section class="portlet grid_12 leading">
		<header>
			<h2>Jantar</h2>
		</header>
		<section>
			<?php
				foreach($dc[5] as $food){
					$checked = '';
					if($food['checked']==1) $checked = 'checked';
					echo'<p>';
					echo'<input name="checkbox'.$food['id'].'" id="checkbox'.$food['id'].'" type="checkbox"'.$checked.'/>';
					echo'		<label for="checkbox'.$food['id'].'">';
					echo'			'.$food['amount_text'].' de '.$food['food_name'];
					echo'		</label>';
					echo'		</p>';
				}
			?>
		</section>
	</section>
	<? endif; ?>
	<? if (isset($dc[6])): ?>
	<section class="portlet grid_12 leading">
		<header>
			<h2>Ceia</h2>
		</header>
		<section>
			<?php
				foreach($dc[6] as $food){
					$checked = '';
					if($food['checked']==1) $checked = 'checked';
					echo'<p>';
					echo'<input name="checkbox'.$food['id'].'" id="checkbox'.$food['id'].'" type="checkbox"'.$checked.'/>';
					echo'		<label for="checkbox'.$food['id'].'">';
					echo'			'.$food['amount_text'].' de '.$food['food_name'];
					echo'		</label>';
					echo'		</p>';
				}
			?>
		</section>
	</section>
	<? endif; ?>
</div>
<script>
	$(document).ready(function(){
		$('input[name^="checkbox"]').change(function(){
			data = {
				"id_dc" : $(this).attr('name').substring(8)
			};

			if($(this).is(':checked')){
				$.post('/ajax/check_food',data);
			} else {
				$.post('/ajax/uncheck_food',data);
			}
		});		
	});		
</script>